﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace MvcCodeNotes
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            // routes.MapRoute(
            //    name: "menu",
            //    url: "ArticleType/{menuid}.html",
            //    defaults: new { controller = "Home", action = "ArticleType", menuid = UrlParameter.Optional }
            //);

            //routes.MapRoute(
            //    name: "Default",
            //    url: "{controller}/{action}/{id}",
            //    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            //);

            //默认Controller是web.config配置的
            string HomeController = ConfigurationManager.AppSettings["HomeController"];
            routes.MapRoute(
               name: "Setting",
               url: "{controller}/{action}/{id}",
               defaults: new { controller = HomeController, action = "Index", id = UrlParameter.Optional }
           );

            //routes.MapRoute(
            //  name: "category",
            //  url: "{controller}/Category/{typeid}/{idx}",
            //  defaults: new { controller = "Book", action = "Category", typeid = UrlParameter.Optional, idx = UrlParameter.Optional }
            //);

            //routes.MapRoute(
            //   name: "Book",
            //   url: "{controller}/{action}/{bid}/{cid}",
            //   defaults: new { controller = "Book", action = "Index", bid = UrlParameter.Optional, cid = UrlParameter.Optional }
            //);



        }
    }
}